home *** CD-ROM | disk | FTP | other *** search
/ Kellogg's Amérique / Kellogg's Amérique / amazonie_en_danger.swf / scripts / elements / Bouton.as
Text File  |  2020-08-04  |  2KB  |  65 lines

  1. package elements
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.events.Event;
  5.    import flash.events.MouseEvent;
  6.    
  7.    public class Bouton extends MovieClip
  8.    {
  9.        
  10.       
  11.       public var clicable:Boolean = true;
  12.       
  13.       private var targetFrame:int = 0;
  14.       
  15.       public var activated:Boolean = false;
  16.       
  17.       public function Bouton()
  18.       {
  19.          activated = false;
  20.          clicable = true;
  21.          targetFrame = 0;
  22.          super();
  23.          gotoAndStop(1);
  24.          buttonMode = true;
  25.          addEventListener(MouseEvent.MOUSE_OVER,_survole);
  26.       }
  27.       
  28.       private function _survole(param1:MouseEvent) : void
  29.       {
  30.          targetFrame = 5;
  31.          addEventListener(Event.ENTER_FRAME,_framing);
  32.          removeEventListener(MouseEvent.MOUSE_OVER,_survole);
  33.          addEventListener(MouseEvent.MOUSE_OUT,_sort);
  34.       }
  35.       
  36.       private function _sort(param1:MouseEvent) : void
  37.       {
  38.          targetFrame = 1;
  39.          addEventListener(Event.ENTER_FRAME,_framing);
  40.          addEventListener(MouseEvent.MOUSE_OVER,_survole);
  41.          removeEventListener(MouseEvent.MOUSE_OUT,_sort);
  42.       }
  43.       
  44.       private function _framing(param1:Event) : void
  45.       {
  46.          if(targetFrame == 0)
  47.          {
  48.             return;
  49.          }
  50.          if(currentFrame == targetFrame)
  51.          {
  52.             removeEventListener(Event.ENTER_FRAME,_framing);
  53.          }
  54.          if(currentFrame > targetFrame)
  55.          {
  56.             prevFrame();
  57.          }
  58.          if(currentFrame < targetFrame)
  59.          {
  60.             nextFrame();
  61.          }
  62.       }
  63.    }
  64. }
  65.